//
//  BilledPieceCell.m
//  ForestPack
//
//  Created by jimmy on 2018/7/24.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#pragma mark - 比稿计件，查看作品，确认合作的cell

#import "BilledPieceCell.h"
#import "Masonry.h"

@implementation BilledPieceCell

+(BilledPieceCell *)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"BilledPieceCell";
    BilledPieceCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[BilledPieceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell creatViewUI];
    }
    return cell;
}

-(void)sureClicked
{
    if (_sureClick) {
        _sureClick();
    }
}

-(void)seeWorksClicked
{
    if (_seeWorksClick) {
        _seeWorksClick();
    }
}

-(void)creatViewUI
{
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"吾诺瀚卓设计师参加竞标";
    nameLabel.textColor = FONTCOLOR_BLACK;
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.font = Kfont(14);
    [self addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.mas_top).offset(10);
        make.width.equalTo(@(SCREEN_WIDTH - 166));
        make.height.equalTo(@24);
    }];
    
    UIButton *sureBtn = [[UIButton alloc] init];
    [sureBtn setTitle:@"确认合作" forState:UIControlStateNormal];
    sureBtn.titleLabel.font = Kfont(12);
    sureBtn.layer.borderColor = RGB_COLOR(237,34,59).CGColor;
    sureBtn.layer.borderWidth = 1.0;
    sureBtn.layer.masksToBounds = YES;
    sureBtn.layer.cornerRadius = 15;
    [sureBtn setTitleColor:RGB_COLOR(237,34,59) forState:UIControlStateNormal];
    [sureBtn addTarget:self action:@selector(sureClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:sureBtn];
    [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-13);
        make.top.equalTo(self.mas_top).offset(7);
        make.width.equalTo(@80);
        make.height.equalTo(@30);
    }];
    
    UIButton *detailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [detailBtn setTitle:@"查看作品" forState:UIControlStateNormal];
    detailBtn.titleLabel.font = Kfont(12);
    [detailBtn setTitleColor:RGB_COLOR(237,34,59) forState:UIControlStateNormal];
    [detailBtn addTarget:self action:@selector(seeWorksClicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:detailBtn];
    [detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(sureBtn.mas_left).offset(-10);
        make.top.equalTo(self.mas_bottom).offset(10);
        make.width.equalTo(@50);
        make.height.equalTo(@24);
    }];
    
    UIImageView *lineImageV = [[UIImageView alloc] init];
    lineImageV.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:lineImageV];
    [lineImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.top.equalTo(self.mas_bottom).offset(-1);
        make.width.equalTo(@(SCREEN_WIDTH));
        make.height.equalTo(@1);
    }];
    
}

@end


#pragma mark - 比稿计件，查看详情的cell

@implementation BilledSeeDetailCell

+(BilledSeeDetailCell *)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"BilledSeeDetailCell";
    BilledSeeDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[BilledSeeDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell creatViewUI];
    }
    return cell;
}

-(void)seeDetail
{
    if (_seeDetailClick) {
        _seeDetailClick();
    }
}

-(void)creatViewUI
{
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"吾诺瀚卓设计师正在设计";
    nameLabel.textColor = FONTCOLOR_BLACK;
    nameLabel.textAlignment = NSTextAlignmentLeft;
    nameLabel.font = Kfont(14);
    [self addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(13);
        make.top.equalTo(self.mas_top).offset(15);
        make.width.equalTo(@(SCREEN_WIDTH - 26-70));
        make.height.equalTo(@20);
    }];
    
    UIButton *detailBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [detailBtn setTitle:@"查看详情" forState:UIControlStateNormal];
    detailBtn.titleLabel.font = Kfont(14);
    [detailBtn setTitleColor:RGB_COLOR(237,34,59) forState:UIControlStateNormal];
    [detailBtn addTarget:self action:@selector(seeDetail) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:detailBtn];
    [detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-13);
        make.top.equalTo(self.mas_top).offset(10);
        make.width.equalTo(@70);
        make.height.equalTo(@24);
    }];
    
    UIImageView *lineImageV = [[UIImageView alloc] init];
    lineImageV.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:lineImageV];
    [lineImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.top.equalTo(self.mas_bottom).offset(-1);
        make.width.equalTo(@(SCREEN_WIDTH));
        make.height.equalTo(@1);
    }];
    
}

@end
